package com.bo.wei.chen.mybatis.design;

/**
 * TODO
 *
 * @author chenwb25485
 * @version V2.1
 * @since 2021/1/21 22:45
 */
public class DependencyInversion {
    public static void main(String[] args) {
        Person person = new Person();
        person.receive(new Email());
        person.receive(new Wechat());
    }
}
interface IReceiver {
    /**
     * 获取消息
     * @return
     */
    String getInfo();
}
class Person {
    public void receive(IReceiver iReceiver) {
        System.out.println(iReceiver.getInfo());
    }
}

class Email implements IReceiver{

    /**
     * 获取消息
     *
     * @return
     */
    @Override
    public String getInfo() {
        return "电子邮件信息:helloWorld!";
    }
}
class Wechat implements IReceiver {
    /**
     * 获取消息
     *
     * @return
     */
    @Override
    public String getInfo() {
        return "微信消息：helloWorld！";
    }
}
